<template>
	<cu-custom show-circle />
	<!-- <view class="page-title">
		宁波智慧教育督导助手
	</view> -->
	
	<view class="white-page">
		<view style="height: calc(50vh - 360rpx);"></view>
		<view class="page-content">
			
			<view class="margin-tb-sm">
				
				<view class="fast-login-btn mb-3">
					<text class="text-blue" @click="switchLogin">验证码登录</text>
				</view>
				<view class="cu-btn bg-blue lg login-btn" @click="handleLogin">授权登录</view>
			</view>
			
			
			
		</view>
	</view>
	
	
</template>

<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app"
import { router } from "@/router"
import store from "@/store/index.js"
import env from "@/env"

interface IAuthcode {
	auth_code?: string
	code: string
}
// interface IData {
// 	code: number
// 	data: string
// 	msg: string
// }
// interface IAuthres {
// 	data: IData
// 	statusCode: number
// }
let loading = false
const handleLogin = ():void => {
	if (loading) return
	loading = true
	uni.showLoading({
		title: "登陆中"
	})
	store.dispatch("fastlogin")
		.then(() => {
			loading = false
			uni.hideLoading()
			router.replaceAll("/pages/index/index")
		})
		.catch(() => {
			loading = false
			uni.hideLoading()
		})
}

const switchLogin = ():void => {
	router.replaceAll("/pages/user/login")
}

onLoad(() => {
	const token = uni.getStorageSync("token")
	if (token) {
		router.replaceAll("/pages/index/index")
	}
})
</script>

<style lang="stylus" scoped>
.white-page
	height: 100vh
	background-color: #fff

.page-title
	position: fixed
	width: 100%
	color: #fff
	font-size: 40rpx
	text-align: center
	margin-top: 22rpx
.cu-form-group
	padding 0
	.title
		min-width: calc(4em + 5px)
.login-btn
	width 100%
.cu-btn
	transition: all .3s
.cu-btn:active
	background-color: #2f61b8
.fast-login-btn
	font-size: 28rpx
</style>
